<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    "http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">
<html><head>
    <title>NKDPostnetBarcode</title>
	<meta name="generator" content="HeaderDoc">
</head><body bgcolor="#ffffff"><h1><font face="Geneva,Arial,Helvtica">NKDPostnetBarcode</font></h1><hr><br>
<h2>Abstract</h2>
US Postal Service mail routing bar code
<h2>Discussion</h2>
This is a two of five barcode that uses the <i>height</i> of the bars, rather
than the width, to encode numeric data
 <hr><br><h2>Methods</h2>

<h3><a name="_encodeChar:">_encodeChar:</a></h3>
<b>Abstract:</b> Simple routine to return five bars separated by double-width gaps

<blockquote><pre><tt>- (NSString *)<B>_encodeChar:</B>(char)<I>inChar;</I> </tt><br>
</pre></blockquote>
<p>All postnet characters are five equally spaced bars of the same width; the encoding is in the bar
heights, so the real work of this subclass is done in the barTop: method
</p>
<b>Result:</b> "100100100100100"
 
<hr>

<h3><a name="_heightForDigit:andBar:">_heightForDigit:andBar:</a></h3>
<b>Abstract:</b> Private method used by the overridden _encodeChar, to determine whether to use a tall or short
bar at a given bar for a particular numeric character

<blockquote><pre><tt>- (float)<B>_heightForDigit:</B>(int)<I>index
</I> <B>andBar:</B>(int)<I>bar;</I> </tt><br>
</pre></blockquote>
<p></p>
<h4>Parameters</h4>
<blockquote>
<table border="1"  width="90%">
<thead><tr><th>Name</th><th>Description</th></tr></thead>
<tr><td align="center"><tt>index</tt></td><td>Integer that specifies the index (0-4 because it's a 2 of 5 code) within an encoded character</td></tr>
<tr><td align="center"><tt>bar</tt></td><td>Index within <i>content</i> of the character we're asking about</td></tr>
</table>
</blockquote>
<b>Result:</b> Either TALL_BAR or SHORT_BAR.
 
<hr>

<h3><a name="barTop:">barTop:</a></h3>
<b>Abstract:</b> Returns the location of the top of a specified bar (assuming origin at lower left)

<blockquote><pre><tt>- (float)<B>barTop:</B>(int)<I>index;</I> </tt><br>
</pre></blockquote>
<p>This method calls out to _heightForDigit:andBar: to find out if a given bar should be a tall bar or short
bar. The top value for tall and short bars are defined constants TALL_BAR and SHORT_BAR
</p>
<b>Result:</b> TALL_BAR or SHORT_BAR corresponding to the top of the specified bar
 
<hr>

<h3><a name="generateChecksum">generateChecksum</a></h3>
<b>Abstract:</b> Generates a simple check digit that is modulus 10 algorithm - add up all the digits, and then however many you
need to add to that sum to make it evenly divisible by 10 is the check digit character
 
<blockquote><pre><tt>- (void)<B>generateChecksum;</B> </tt><br>
</pre></blockquote>
<p></p>
<hr>

<h3><a name="initWithContent:printsCaption">initWithContent:printsCaption</a></h3>
<b>Abstract:</b> Overridden method that sets values for this barcode according to USPS specifications

<blockquote><pre><tt>- (id)<B>initWithContent:</B>(NSString *)inContent
      <I></I> <B>printsCaption:</B>(BOOL)<I>inPrints;</I> </tt><br>
</pre></blockquote>
<p>We are using a bar width of .015" and a gap space of .030" - this spacing is within the US Postal
Service's specs and since the gap space is exactly twice the bar width, we can represent the gap
with two zeros and represent all bars as one one. The real logic for this barcode is in the barTop
method, which makes it a somewhat unusual subclass of NKDBarcode.
<br><br>
This constructor also calculates the checkdigit; Check digit is a mandatory part of PostNet.
</p>
<h4>Parameters</h4>
<blockquote>
<table border="1"  width="90%">
<thead><tr><th>Name</th><th>Description</th></tr></thead>
<tr><td align="center"><tt>inContent</tt></td><td>The content to be encoded</td></tr>
<tr><td align="center"><tt>inPrints</tt></td><td>Ignored; PostNet never uses a caption.</td></tr>
</table>
</blockquote>
<b>Result:</b> Initialized barcode encoding <i>content</i> using PostNet encoding
 
<hr>

<h3><a name="initiator">initiator</a></h3>
<b>Abstract:</b> Initiator in PostNet is a single tall bar plus a gap of twice the bar width.

<blockquote><pre><tt>- (NSString *)<B>initiator;</B> </tt><br>
</pre></blockquote>
<p></p>
<b>Result:</b> "100"
 
<hr>

<h3><a name="printsCaption">printsCaption</a></h3>
<b>Abstract:</b> Overridden because PostNet NEVER uses a caption

<blockquote><pre><tt>- (BOOL)<B>printsCaption;</B> </tt><br>
</pre></blockquote>
<p></p>
<b>Result:</b> NO
 
<hr>

<h3><a name="terminator">terminator</a></h3>
<b>Abstract:</b> Terminating character in PostNet is a single tall bar.

<blockquote><pre><tt>- (NSString *)<B>terminator;</B> </tt><br>
</pre></blockquote>
<p></p>
<b>Result:</b> "1"
 
<hr>
<p>(Last Updated 4/21/2003)
</p></body></html>
